package com.bolt.admin.module.sys.repository;

import com.bolt.admin.module.sys.entity.MenuEntity;
import com.bolt.support.spring.jpa.repository.BasicJpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.jpa.repository.QueryHints;
import org.springframework.data.repository.query.Param;

import javax.persistence.QueryHint;
import java.math.BigInteger;
import java.util.List;

/**
 * @author michao
 * Created by Administrator on 2017/9/28.
 */
public interface MenuRepository extends BasicJpaRepository<MenuEntity, Long> {

    @Query("select count(id) from MenuEntity where parent=:parent")
    long findChildrenSize(@Param("parent") MenuEntity parent);

    @Query("from MenuEntity order by orderRank ")
    List<MenuEntity> findAllCached();

    @Query("from MenuEntity where lft+1 = rgt  order by orderRank desc")
    List<MenuEntity> findAllChildrenMenu();

}
